import React, { useEffect } from 'react'
import { HashRouter } from 'react-router-dom'
import { Provider } from 'react-redux'
import Cookies from 'js-cookie'
import store, { actionCreators } from '../store'
import Container from '../components/container'
import { TOKEN_KEY } from '../constants'
import './App.scss'

function App() {
  useEffect(() => {
    const token = Cookies.get(TOKEN_KEY)
    store.dispatch(actionCreators.setLoginStatus(!!token))
  }, [])

  return (
    <div className="App">
      <Provider store={store}>
        <HashRouter>
          <Container/>
        </HashRouter>
      </Provider>
    </div>
  )
}

export default App
